<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box">
      <input type="text" name="" id="" placeholder="请输入内容" /><br />
      <input type="text" name="" id="" placeholder="请输入内容" /><br />
      <input type="text" name="" id="" placeholder="请输入内容" /><br />
      <input type="text" name="" id="" placeholder="请输入内容" /><br />
      <input type="text" name="" id="" placeholder="请输入内容" />
    </div>
    <script>
      var box = document.getElementById('box')
      var inputs = box.getElementsByTagName('input')
      for (var i = 0; i < inputs.length; i++) {
        inputs[i].addEventListener('focus', function () {
          for (var k = 0; k < inputs.length; k++) {
            inputs[k].style.backgroundColor = '#FFF'
          }
          this.style.backgroundColor = '#CCC'
        })
      }
    </script>
  </body>
</html>
